package com.weiyi.mashangzhu.Roomer.Adapter;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.weiyi.mashangzhu.R;
import com.weiyi.mashangzhu.Roomer.Activity.HouseDetailsActivity;
import com.weiyi.mashangzhu.Roomer.Bean.SysMessageBean;

import java.util.List;

/**
 * Created by win7 on 2017/5/12.
 */

public class SysMsgAdapter extends BaseAdapter {
    List<SysMessageBean.DataBean> list;
    Context context;

    public SysMsgAdapter(List<SysMessageBean.DataBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_sys_msg_list, null);
            viewHolder.time = (TextView) convertView.findViewById(R.id.sys_msg_time);
            viewHolder.title = (TextView) convertView.findViewById(R.id.sys_msg_title);
            viewHolder.content = (TextView) convertView.findViewById(R.id.sys_msg_content);
            convertView.setTag(viewHolder);

        }
        viewHolder = (ViewHolder) convertView.getTag();
        viewHolder.time.setText(list.get(position).getMsgTime()+"");
        viewHolder.title.setText(list.get(position).getMsgTitle()+"");
        viewHolder.content.setText(list.get(position).getMsgContent()+"");
        return convertView;
    }

    class ViewHolder {
        TextView time,title,content;
    }
}
